﻿public class Solution75
{
    public void SortColors(int[] nums)
    {


        int len = nums.Length;
        int p0 = 0;
        int p1 = 0;
        for (int i = 0; i < len; i++)
        {



            if (nums[i] == 0)
            {

                MySwap(nums, p0, i);

                if (p1 > p0)
                {
                    MySwap(nums, p1, i);

                }
                p0++;
                p1++;

            }
            else if (nums[i] == 1)
            {
                MySwap(nums, p1, i);
                p1++;
            }



        }




    }
    void MySwap(int[] nums, int left, int right)
    {


        int temp = nums[left];
        nums[left] = nums[right];
        nums[right] = nums[left];
    }

}


